<template>
    <section class="modlude">
        <el-form :inline="true" :model="formSearch" class="form_inline">
            <!-- <el-form-item label="所属组织" size="small">
            <el-cascader
                ref="cascader"
                v-model="option1"
                :options="dataTree"
                :props="defaultProps2"
                @change="handleChange"
                clearable
              >
              </el-cascader>
          </el-form-item> -->
            <el-form-item label="所属项目" size="small">
                <el-select v-model="formSearch.projectId" clearable placeholder="请选择项目">
                    <el-option v-for="(item,index) in xqTree" :label="item.name" :value="item.id" :key="index">
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="计划名称" size="small">
                <el-input v-model="formSearch.name" placeholder="请输入计划名称"></el-input>
            </el-form-item>
            <!-- <el-form-item label="状态" size="small">
          <el-select v-model="formSearch.status" placeholder="请选择目前状态">
            <el-option label="全部" :value="''"></el-option>
            <el-option label="已启用" :value="1"></el-option>
            <el-option label="已停用" :value="2"></el-option>
          </el-select>
        </el-form-item> -->
        <!-- v-if="$root.btnControl.find(item=>item=='view')" -->
            <el-form-item size="small">
                <el-button   @click="getlist">查 询
                </el-button>
            </el-form-item>

            <!-- v-if="$root.btnControl.find(item=>item=='add')" -->
            <el-form-item size="small">
                <el-button   type="primary" 
                    @click="addDialog = true">新增巡查计划
                </el-button>
            </el-form-item>
            <el-form-item size="small">
                <el-button  @click="goywjichupeizhi">去配置</el-button>
            </el-form-item>

        </el-form>
        <el-table :data="formData" style="width: 100%">

            <el-table-column prop="projectName" label="所属项目"></el-table-column>
            <el-table-column prop="name" label="计划名称"></el-table-column>
            <el-table-column prop="pathName" label="巡查路线"></el-table-column>
            <el-table-column prop="yunweirenyuan" label="巡查人员"></el-table-column>
            <el-table-column prop="" label="班次频率">
                <template slot-scope="scope">
                    {{scope.row.frequencyType==1?"每月循环":scope.row.frequencyType==2?"每周循环":'间隔循环'}}
                </template>
            </el-table-column>
            <!-- <el-table-column prop="name" label="巡查日期"></el-table-column> -->
            <el-table-column label="巡查执行时间段">
                <template slot-scope="scope">
                    {{scope.row.stime !=''?scope.row.stime:''}}
                    --
                    {{scope.row.etime !=''?scope.row.etime:''}}
                </template>
            </el-table-column>
            <el-table-column label="状态">
                <template slot-scope="scope">
                    {{scope.row.enabled ==0?'停止':'启用'}}
                </template>
            </el-table-column>
            <el-table-column label="操作" fixed="right" width=310>
                <template slot-scope="scope">
                    <!-- v-if="$root.btnControl.find(item=>item=='enable')" -->
                    <el-button type="" size="small"  @click="enabledyron(scope.row.id,scope.row.enabled)">
                        {{scope.row.enabled==0?'启用':'停用'}}</el-button>
                    <!-- <el-button type="" size="small" @click="goyunweirw">巡查记录</el-button> -->
                    <!-- v-if="$root.btnControl.find(item=>item=='edit')" -->
                    <el-button type=""  size="small" 
                        @click="xiangqing(scope.row,2)">修改</el-button>
                        <!-- v-if="$root.btnControl.find(item=>item=='view')" -->
                    <el-button type=""  size="small" 
                        @click="xiangqing(scope.row,3)">详情</el-button>
                        <!-- v-if="$root.btnControl.find(item=>item=='delete')" -->
                    <el-button type="danger"  size="small" 
                        @click="deleinfor(scope.row.id)">删除</el-button>
                </template>
            </el-table-column>
        </el-table>
        <paging @changePage=handleCurrentPage :get-total='total'></paging>
        <!-- 新增 -->
        <el-dialog :title="xzxgbs==1? '新增' :xzxgbs==3? '详情':'修改'" top="6vh" :visible.sync="addDialog" @close="canceladd"
            :close-on-click-modal="false">
            <div class="cont_box_right">
                <el-form label-position="right" label-width="100px" :model="formPush" ref='ywjhlist'>

                    <el-form-item label="选择项目" size="small" prop="projectId" :rules="{
                        required: true, message: '该项不能为空', trigger: 'blur'
                    }">
                        <el-select @change="xqidtodata" v-model="formPush.projectId" placeholder="请选择项目">
                            <el-option v-for="(item,index) in xqTree" :label="item.name" :value="item.id" :key="index">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="巡查路线" size="small" prop="pathId" :rules="{
                        required: true, message: '该项不能为空', trigger: 'blur'
                    }">
                        <el-select @change="" v-model="formPush.pathId" placeholder="请选择巡查路线">
                            <el-option v-for="(item,index) in pathdata" :label="item.name" :value="item.id"
                                :key="item.id"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="任务名称" prop="name" size="small" :rules="{
                        required: true, message: '该项不能为空', trigger: 'blur'
                    }">
                        <el-input v-model="formPush.name" placeholder="请输入名称"></el-input>
                    </el-form-item>
                    <el-form-item label="巡查日期" size="small" :rules="{
                        required: true, message: '该项不能为空', trigger: 'blur'
                    }">
                        <el-radio-group v-model="formPush.inspectType" style="font-size: 15px;" @change="inspectType">
                            <div class="radiodiv">
                                <el-radio style="width: 100px;" :label="1">指定某天</el-radio>
                                <el-date-picker v-model="inspectEndTime1" type="date" placeholder="选择日期">
                                </el-date-picker>
                            </div>
                            <div class="radiodiv">
                                <el-radio style="width: 100px;" :label="2">指定某时间段</el-radio>
                                <el-date-picker class="asdf" v-model="zdsjd" type="daterange" range-separator="至"
                                    start-placeholder="开始日期" end-placeholder="结束日期">
                                </el-date-picker>
                            </div>
                            <div class="radiodiv">
                                <el-radio style="width: 100px;" :label="3">指定某天起</el-radio>
                                <el-date-picker v-model="inspectEndTime3" type="date" placeholder="选择日期">
                                </el-date-picker>
                                <span slot="suffix" style="margin-left: 10px; font-size: 15px;">起</span>
                            </div>
                        </el-radio-group>
                    </el-form-item>
                    <el-form-item label="班次频率" v-if="formPush.inspectType !=1" size="small" :rules="{
                        required: true, message: '该项不能为空', trigger: 'blur'
                    }">
                        <el-radio-group v-model="formPush.frequencyType" @change="frequencyType">
                            <div class="radiodiv">
                                <el-radio style="width: 100px;" :label="1">每月循环</el-radio>
                                <!-- <el-input class="myxhnumber" v-model="meiyuexh"></el-input> -->
                                <el-select class="myxhnumber" style="margin-left:10px" v-model="meiyuexh"
                                    placeholder="">
                                    <el-option v-for="(item,index) in dayTree" :label="item.name" :value="item.name"
                                        :key="index">
                                    </el-option>
                                </el-select>
                                <span slot="suffix" style="margin-left: 10px; font-size: 15px;">日</span>

                            </div>
                            <div class="radiodiv">
                                <el-radio style="width: 100px;" :label="2">每周循环</el-radio>
                                <el-checkbox-group style="display: inline-block;" v-model="checkboxGroup1">
                                    <el-checkbox-button v-for="city in cities" :label="city.day" :key="city.name">
                                        {{city.name}}
                                    </el-checkbox-button>
                                </el-checkbox-group>
                            </div>
                            <div class="radiodiv">
                                <el-radio style="width: 100px;" :label="3">间隔循环</el-radio>
                                <span slot="suffix" style="margin-right: 10px; font-size: 15px;">间隔</span>
                                <!-- <el-input class="jgxhtime" v-model="jgxhvalue"></el-input> -->
                                <el-select class="myxhnumber" style="margin-left:10px" v-model="jgxhvalue"
                                    placeholder="">
                                    <el-option v-for="(item,index) in dayTree" :label="item.name" :value="item.name"
                                        :key="index">
                                    </el-option>
                                </el-select>
                                <span slot="suffix" style="margin-left: 10px; font-size: 15px;">日</span>
                            </div>
                        </el-radio-group>
                    </el-form-item>
                    <el-form-item label="执行时间段" size="small" :rules="{
                        required: true, message: '该项不能为空', trigger: 'blur'
                    }">
                        <div class="radiodiv">
                            <el-time-picker  is-range v-model="zxsjd" range-separator="至"
                                start-placeholder="开始时间" end-placeholder="结束时间" placeholder="选择时间范围">
                            </el-time-picker>
                        </div>
                    </el-form-item>


                    <el-form-item label="巡查人员" :rules="{
                        required: true, message: '此项不能为空', trigger: 'blur'
                    }">
                        <el-select v-model="value2" size="small" multiple placeholder="请选择">
                            <el-option v-for="item in ywrydata" :key="item.id" :label="item.name" :value="item.id">
                            </el-option>
                        </el-select>
                    </el-form-item>

                    <el-form-item label="是否启用" prop="enabled" :rules="{
                        required: true, message: '该项不能为空', trigger: 'blur'
                    }">
                        <el-radio v-model="formPush.enabled" :label="0">否</el-radio>
                        <el-radio v-model="formPush.enabled" :label="1">是</el-radio>
                    </el-form-item>
                    <el-form-item label="备注" prop="remark" size="small">
                        <el-input type="textarea" autosize placeholder="请输入内容" v-model="formPush.remark">
                        </el-input>
                    </el-form-item>
                </el-form>
            </div>
            <div class="dialog-footer" style="text-align: center;">
                <!-- <el-button size="medium " @click="canceladd">取 消</el-button> -->
                <el-button size="medium " v-if='xzxgbs ==1 ||  xzxgbs ==2' @click="addlist">提 交</el-button>
            </div>
        </el-dialog>

    </section>
</template>

<script>
    import paging from "../paging"
    import { getDateArray } from '../../util/util'
    import {
        deletePatrolTask,
        addPatrolTask,
        getPatrolTaskList,
        xqSelectList,
        getPatrolPathList,
        orgTree,
        getInvestigatorsList,
        updPatrolTask,
    } from '../../url/api';
    export default {
        data() {
            return {
                xzxgbs: 1,
                zdsjd: [],
                zxsjd: [new Date(), new Date()],//执行时间段
                inspectEndTime1: '',
                inspectEndTime3: '',
                meiyuexh: '',//每月循环
                checkboxGroup1: [],//每周循环
                jgxhvalue: '',//间隔循环
                dayTree: [],
                ywrydata: [],
                value2: [],
                value3: '',
                dynamicTags: [],//tag
                checkStrictly: false,
                bindRole: {},
                showmenuList: [],
                menuList: [],
                option1: [],
                xqTree: [],
                pathdata: [],
                isAddorUpdate: 1,//1添加、2修改
                formSearch: {
                    current: 1,
                    size: 10,
                    type:1,
                    projectId:'',
                },

                pro_type: 1,//1.报修类型2.物业缴费类型3.家庭事务类型
                formData: [],//数据
                // deleBatch: [],//删除数据
                // formUpdate:{},//修改表单
                total: 0,//数据总数
                pages: 0,//页面总数
                addDialog: false,
                // updateDialog:false,
                // dialog:false,
                formPush: {
                    projectId: '',
                    name :'',
                    // groupingId : '',
                    pathId:'',
                    inspectType : '',
                    frequencyType :'',
                    enabled : '',
                    remark : '',
                    inspectType: 1,
                    frequencyType: 1,
                    enabled: 0,
                    patrolTimeDTOS: [
                        {
                            executionStartTime: '',
                            executionEndTime: ''
                        }
                    ],
                    type:1,
                },
                cities: [
                    { name: '周一', day: 1 }, { name: '周二', day: 2 }, { name: '周三', day: 3 },
                    { name: '周四', day: 4 }, { name: '周五', day: 5 }, { name: '周六', day: 6 }, { name: '周日', day: 7 }],
                dataTree: [],
                // defaultProps: {//树状图key定义
                //   children: 'data',
                //   label: 'name'
                // },
                defaultProps2: {
                    children: 'children',
                    label: 'name',
                    value: 'id',
                    expandTrigger: 'hover', checkStrictly: true
                },
                // rules: {
                //   name: [{ required: true, message: '该项不能为空', trigger: 'change' }],
                //   phone: [{ required: true, message: '该项不能为空', trigger: 'change' }],
                //   identity: [{ required: true, message: '该项不能为空', trigger: 'change' }],
                //   department: [{ required: true, message: '该项不能为空', trigger: 'change' }],
                //   sex: [{ required: true, message: '该项不能为空', trigger: 'change' }],
                //   idNumberType: [{ required: true, message: '该项不能为空', trigger: 'change' }],
                //   projectId: [{ required: true, message: '该项不能为空', trigger: 'change' }],
                // },
                imageUrl: ''
            }
        },
        methods: {
            enabledyron(id, enabled) {
                let text = ''
                if (enabled == 0) {
                    enabled = 1
                    text = '确定启用？'
                } else {
                    enabled = 0
                    text = '确定停用？'
                }
                let params = {
                    enabled: enabled,
                    id: id
                }
                this.$confirm(text, '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    //console.log("params", params)
                    updPatrolTask(params).then((res) => {
                        if (res.data.ok) {
                            this.addDialog = false
                            this.$message({
                                message: '操作成功',
                                type: 'success'
                            });
                            this.getlist();

                        } else {
                            this.$message('操作失败');
                        }
                    })
                    //this.$message('还没有启用或者停用接口！')

                })

            },
            goyunweirw() {
                this.$router.push({
                    path: '/property_device_operation_plan',
                    query: {
                        isActive: 2
                    }
                })
            },
            goywjichupeizhi() {//报修类型配置
                this.$router.push({
                    path: '/property_inspection_config',//property_maintenance_repair

                })
            },
            canceladd() {
                this.addDialog = false
                this.xzxgbs = 1
                if (this.formPush.projectId == '') {
                    this.$message('请选择项目！')
                    return
                }
                this.formPush = {
                    projectId: '',
                    name :'',
                    pathId : '',
                    inspectType : '',
                    frequencyType :'',
                    enabled : '',
                    remark : '',
                    inspectType: 1,
                    frequencyType: 1,
                    enabled: 0,
                    patrolTimeDTOS: [
                        {
                            executionStartTime: '',
                            executionEndTime: ''
                        }
                    ],
                    type:1,
                }
                this.zdsjd = []
                this.zxsjd = [new Date(), new Date()]//执行时间段
                this.inspectEndTime1 = ''
                this.vinspectEndTime3 = ''
                this.meiyuexh = ''//每月循环
                this.checkboxGroup1 = []//每周循环
                this.jgxhvalue = ''//间隔循环
                this.ywrydata = []
                this.pathdata = []
                this.value2 = []
            },
            xiangqing(row, index) {
                this.zdsjd = []
                this.zxsjd = []
                this.xzxgbs = index
                this.addDialog = true
                this.formPush.projectId = row.projectId
                this.formPush.name = row.name
                this.formPush.pathId = row.pathId
                this.formPush.inspectType = row.inspectType
                this.formPush.frequencyType = row.frequencyType
                this.formPush.enabled = row.enabled
                this.formPush.remark = row.remark
                this.formPush.id = row.id
                let params = {
                    projectId: row.projectId,
                    type:1
                }
                getPatrolPathList(params).then((res) => {//
                    console.log("巡查路线列表列表:", res)
                    if (res.data.ok) {
                        this.pathdata = res.data.data.records.filter((item) => {
                            return item
                        })
                        //this.total = res.data.data.total
                    } else {
                        this.$message(res.data.msg);
                    }
                })
                let ryparams = {
                    projectId: row.projectId,
                    roleType:1
                }
                getInvestigatorsList(ryparams).then((res) => {//巡查人员列表
                    console.log("巡查人员列表:", res)
                    if (res.data.ok) {
                        this.ywrydata = res.data.data.records.filter((item) => {
                            return item
                        })
                    } else {
                        this.$message(res.data.msg);
                    }
                })

                if (row.inspectType == 1) {
                    this.inspectEndTime1 = row.inspectStartTime
                }
                if (row.inspectType == 2) {
                    this.zdsjd[0] = row.inspectStartTime
                    this.zdsjd[1] = row.inspectEndTime
                    //console.log(this.zdsjd);
                }
                if (row.inspectType == 3) {
                    this.inspectEndTime3 = row.inspectStartTime
                }

                if (row.frequencyType == 1) {
                    this.meiyuexh = row.frequencyDay
                }
                if (row.frequencyType == 2) {
                    let strarry = row.frequencyDay.split('_')
                    strarry.forEach((iem) => {
                        this.checkboxGroup1.push(parseInt(iem))
                    })

                    //  this.checkboxGroup1 = parseInt(strarry)

                    //console.log(this.checkboxGroup1);
                }
                if (row.frequencyType == 3) {
                    this.jgxhvalue = row.frequencyDay
                }
                if (row.patrolTimeDTOS.length != 0) {
                    this.zxsjd[0] = row.patrolTimeDTOS[0].executionStartTime
                    this.zxsjd[1] = row.patrolTimeDTOS[0].executionEndTime
                }
                //row.inspectorsId = 
                if (row.ryids) {
                    this.value2 = row.ryids
                }

            },

            deleinfor(id) {
                let params = [
                    id
                ]

                this.$confirm("确定要删除吗？", '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    deletePatrolTask(params).then((res) => {
                        //console.log("删除", res)
                        if (res.data.ok) {
                            this.$message({
                                message: '删除成功',
                                type: 'success'
                            });
                            this.getlist()
                        } else {
                            this.$message('删除失败')
                        }
                    })

                }).catch(_ => { });

            },

            xqidtodata(id) {

                let params = {
                    projectId: id,
                    type:1
                }
                getPatrolPathList(params).then((res) => {//
                   console.log("巡查路线列表:", res)
                    if (res.data.ok) {
                        this.pathdata = res.data.data.records.filter((item) => {
                            return item
                        })
                        //this.total = res.data.data.total
                    } else {
                        this.$message(res.data.msg);
                    }
                })
                let ryparams = {
                    projectId: id,
                    roleType:1
                }
                getInvestigatorsList(ryparams).then((res) => {//巡查人员列表
                    //console.log("巡查人员列表:", res)
                    if (res.data.ok) {
                        this.ywrydata = res.data.data.records.filter((item) => {
                            return item
                        })
                    } else {
                        this.$message(res.data.msg);
                    }
                })

            },
            addlist() {
                //xcrylist
                console.log("hahahaha",this.formPush)

                if (this.formPush.inspectType == '') {
                    this.$message('请选择巡查日期！')
                    return
                } else {
                    delete this.formPush.inspectStartTime
                    delete this.formPush.inspectEndTime

                    if (this.formPush.inspectType == 1 && this.inspectEndTime1 == '') {
                        this.$message('请填写指定某天日期！')
                        return
                    } else if (this.formPush.inspectType == 1 && this.inspectEndTime1 != '') {
                        this.formPush.inspectStartTime = new Date(this.inspectEndTime1).getTime()
                        //console.log(this.formPush.inspectStartTime);
                    }

                    if (this.formPush.inspectType == 2 && this.zdsjd == '') {
                        this.$message('请填写指定某时间段日期！')
                        return
                    } else if (this.formPush.inspectType == 2 && this.zdsjd.length != 0) {
                        this.formPush.inspectStartTime = new Date(this.zdsjd[0]).getTime()
                        this.formPush.inspectEndTime = new Date(this.zdsjd[1]).getTime()
                        //console.log(this.formPush.inspectStartTime, this.formPush.inspectEndTime);
                    }

                    if (this.formPush.inspectType == 3 && this.inspectEndTime3 == '') {
                        this.$message('请填写指定某天起日期！')
                        return
                    } else if (this.formPush.inspectType == 3 && this.inspectEndTime3 != '') {
                        this.formPush.inspectStartTime = new Date(this.inspectEndTime3).getTime()
                        //console.log(this.formPush.inspectStartTime);
                    }
                }

                if (this.formPush.inspectType != 1) {
                    if (this.formPush.frequencyType == '') {
                        this.$message('请选择班次频率！')
                    } else {
                        if (this.formPush.frequencyType == 1 && this.meiyuexh == '') {
                            this.$message('请选择每月循环日期！')
                            return
                        } else if (this.formPush.frequencyType == 1 && this.meiyuexh != '') {
                            this.formPush.frequencyDay = this.meiyuexh
                            //console.log(this.formPush.frequencyDay);
                        }

                        if (this.formPush.frequencyType == 2 && this.checkboxGroup1.length == 0) {
                            this.$message('请选择每周循环时间！')
                            return
                        } else if (this.formPush.frequencyType == 2 && this.checkboxGroup1.length != 0) {
                            //console.log(this.checkboxGroup1);
                            this.formPush.frequencyDay = this.checkboxGroup1.join('_')
                            //console.log(this.formPush.frequencyDay);
                        }
                        if (this.formPush.frequencyType == 3 && this.jgxhvalue == '') {
                            this.$message('请选择间隔循环日期！')
                            return
                        } else if (this.formPush.frequencyType == 3 && this.jgxhvalue != '') {
                            this.formPush.frequencyDay = this.jgxhvalue
                            //console.log(this.formPush.frequencyDay);
                        }
                    }
                }

                if (this.value2.length != 0) {
                    this.formPush.inspectorsId = this.value2
                } else {
                    this.$message('请选择巡查人员！')
                    return
                }
                //console.log(this.zxsjd);
                if (this.zxsjd.length != 0) {
                    this.formPush.patrolTimeDTOS[0].executionStartTime = new Date(this.zxsjd[0]).getTime()
                    this.formPush.patrolTimeDTOS[0].executionEndTime = new Date(this.zxsjd[1]).getTime()
                } else {
                    this.$message('请填写执行时间段！')
                }
                console.log(this.formPush)
                this.$refs.ywjhlist.validate((valid) => {
                    //console.log("valid", valid)
                    if (valid) {

                        this.$confirm("确定要执行此操作吗？", '提示', {
                            confirmButtonText: '确定',
                            cancelButtonText: '取消',
                            type: 'warning'
                        }).then(() => {
                            if (this.xzxgbs == 1) {
                                //delete this.formPush.id
                                addPatrolTask(this.formPush).then((res) => {
                                    //console.log("新增", res)
                                    if (res.data.ok) {
                                        this.$message({
                                            message: '添加成功',
                                            type: 'success'
                                        });
                                        this.getlist()

                                    } else {
                                        this.$message('添加失败')
                                    }
                                    this.addDialog = false
                                })

                            } else if(this.xzxgbs == 2) {
                                updPatrolTask(this.formPush).then((res) => {
                                    //console.log("新增", res)
                                    if (res.data.ok) {
                                        this.$message({
                                            message: '修改成功',
                                            type: 'success'
                                        });
                                        this.getlist()

                                    } else {
                                        this.$message('修改失败')
                                    }
                                    this.addDialog = false
                                })
                            }

                        }).catch(_ => { });

                    } else {
                        //console.log('error submit!!');
                        return false;
                    }
                });




                //console.log(this.formPush);
            },

            inspectType(data) {
                if (data == 1) {
                    this.zdsjd = []
                    this.inspectEndTime3 = ''
                } else if (data == 2) {
                    this.inspectEndTime1 = ''
                    this.inspectEndTime3 = ''
                    //console.log(this.zdsjd[0]);
                } else if (data == 3) {
                    this.inspectEndTime1 = ''
                    this.zdsjd = []
                }



                //console.log(data);

            },

            frequencyType(data) {
                // this.formPush.frequencyDay = ''
                if (data == 1) {
                    // meiyuexh = ''
                    this.checkboxGroup1 = []
                    this.jgxhvalue = ''

                } else if (data == 2) {
                    this.meiyuexh = ''
                    //checkboxGroup1 = []
                    this.jgxhvalue = ''
                    //this.formPush.frequencyDay = this.checkboxGroup1.join('_')
                    //console.log(this.formPush.frequencyDay);
                } else if (data == 3) {
                    this.meiyuexh = ''
                    this.checkboxGroup1 = []
                    //jgxhvalue = ''

                }
                //console.log(data);
                //console.log(this.zdsjd);


            },
            
            //---------tag 标签------
            handleClose(tag) {
                for (var i = 0; i < this.dynamicTags.length; i++) {
                    if (tag.id === this.dynamicTags[i].id) {//以id作为key进行比对
                        this.dynamicTags.splice(i, 1);//删除对应id的tag
                        this.$refs.multipleTable2.toggleRowSelection(tag, false);//同时取消表格中对应行的勾选状态
                    }
                }
                // this.dynamicTags.splice(this.dynamicTags.indexOf(tag), 1);
            },



            getlist() {
                getPatrolTaskList(this.formSearch).then((res) => {
                    console.log("巡查计划列表", res)
                    if (res.data.ok) {
                        this.formData = res.data.data.records.filter((item) => {
                            if (item.patrolTimeDTOS && item.patrolTimeDTOS.length>0) {
                                item.stime = getDateArray(item.patrolTimeDTOS[0].executionStartTime)[11]
                                item.etime = getDateArray(item.patrolTimeDTOS[0].executionEndTime)[11]
                            }
                            if (item.inspectorsName) {
                                let ryarry = []
                                let ryids = []
                                item.inspectorsName.forEach(val => {
                                    ryarry.push(val.name)
                                    ryids.push(val.id)
                                })
                                item.ryids = ryids
                                if (ryarry.length > 2) {
                                    item.ywrydata = ryarry.join('、')
                                    item.yunweirenyuan = ryarry[0] + '、' + ryarry[1] + ' . . .'

                                } else {
                                    item.yunweirenyuan = ryarry.join('、')
                                    item.ywrydata = ryarry.join('、')
                                }

                                //item.yunweirenyuan = item.inspectorsName.name.join(',')
                            }
                            return item
                        })
                        this.total = res.data.data.total
                    } else {
                        this.$message(res.data.msg);
                    }
                })
            },
            getInit() {
                
                xqSelectList({}).then((res) => {//项目选择列表
                    //console.log(res)
                    if (res.data.ok) {
                        this.xqTree = res.data.data;
                        this.formSearch.projectId = res.data.data[0].id;
                    }
                    this.getlist();
                })
                let org_tree = {
                    name: '',
                    status: 1
                }
                orgTree(org_tree).then((res) => {//获取组织列表
                    //console.log(res)
                    if (res.data.ok) {
                        this.dataTree = res.data.data
                    }
                })





                //---天
                for (var count3 = 1; count3 <= 31; count3++) {
                    let numberdata = {};
                    numberdata.name = count3
                    this.dayTree.push(numberdata)
                };


            },

            handleCurrentPage(val) {//页码改变
                this.formSearch.current = val
                this.getlist()
            },
        },
        mounted() {
            this.getInit();
            // this.getlist()
        },

        components: {
            paging
        }
    }
</script>
<style scoped>
    .radiodiv {
        margin-bottom: 20px;
    }

    .asdf .el-input__inner {
        width: 232px;
        max-width: 240px;
        color: #fff;
    }

    .el-date-editor .el-range-input {
        color: #fff;
    }

    .el-date-editor .el-range-separator {
        color: #fff;
    }

    .radiodiv>>>.asdf {
        width: 260px;
        max-width: 260px;
    }

    .radiodiv>>>.el-range-separator {
        color: #fff;
    }

    .radiodiv>>>.el-range-input {
        color: #fff;
    }

    .radiodiv>>>.selectdiv input {
        width: 60px;
        min-width: 60px;
        margin-left: 10px;
    }

    .jgxhtime>>>.el-input__inner {
        width: 100px;
        max-width: 100px;
        min-width: 100px;
    }

    .myxhnumber>>>.el-input__inner {
        width: 50px;
        min-width: 50px;
        max-width: 50px;
    }

    .radiodiv>>>.el-checkbox-button {
        margin-right: 10px;
        border-radius: 5px;
    }

    .radiodiv>>>.el-checkbox-button__inner {
        border-radius: 5px;
    }
</style>